package br.ufrj.ppgi.infovis.styles;

import org.mt4j.util.MTColor;

public class Category {
	
	private String name;
	private  MTColor color;
	private String icon;
	
	private final MTColor defaultColor=MTColor.GREEN;
	
	public Category (String name, String color, String icon){
		
		this.name = name;
		
		if (color.equals("default")) {
			this.color = defaultColor;
		} else {
			float[] rgb = hexaToRGB(color);
			this.color  = new MTColor(rgb[0],rgb[1],rgb[2]);
		}
		
		this.icon = icon;	
		
	}
	
	private float[] hexaToRGB(String hexa){
		
		// #6CC41A
		float[] ret = new float[3];
		
		String r = hexa.substring(1, 3);
		String g = hexa.substring(3, 5);
		String b = hexa.substring(5, 7);
		
		ret[0]=(float) Integer.parseInt(r, 16);
		ret[1]=(float) Integer.parseInt(g, 16);
		ret[2]=(float) Integer.parseInt(b, 16);		
		
		return ret;
		
		
	}

	public String getName() {
		return name;
	}

	public MTColor getColor() {
		return color;
	}

	public String getIcon() {
		return icon;
	}
	
	
	

}
